package com.itic.ht.actcms.knowledgedetail.service;

import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.itic.appbase.framework.common.basevo.User;
import com.itic.appbase.framework.common.constants.DBConst;
import com.itic.appbase.framework.common.constants.IticConst;
import com.itic.appbase.framework.common.service.CrudService;
import com.itic.appbase.framework.utils.IdGen;
import com.itic.ht.actcms.knowledgedetail.persistence.dao.WebKnowledgeDetailDao;
import com.itic.ht.actcms.knowledgedetail.persistence.model.WebKnowledgeDetail;
import com.itic.ht.actcms.knowledgedetail.persistence.model.WebKnowledgeDetailExample;


@Service
@Transactional
public class WebKnowledgeDetailService extends CrudService<WebKnowledgeDetailDao,WebKnowledgeDetail,WebKnowledgeDetailExample> {
    @Autowired
    private WebKnowledgeDetailDao webKnowledgeDetailDao;

    //批量导入业务
	public String imp(HttpServletRequest request,List<WebKnowledgeDetail> dataList) {
		if(dataList.size()>0){
			Date date = new Date();
			User user = (User)request.getSession().getAttribute(IticConst.PS_SESSION_USERINFO_KEY);
			
			for(WebKnowledgeDetail temp:dataList){
				temp.setId(IdGen.uuid());
				temp.setCreateTime(date);
				temp.setUpdateTime(date);
				temp.setIsEffective(DBConst.TRUE);
				
				temp.setOrgCode(user.getOrg());
				temp.setCreateUser(user.getId());
				webKnowledgeDetailDao.insert(temp);
			}
		}
		return "success";
	}



}